//
//  BaseTableViewController.swift
//  TakeTime
//
//  Created by bachelor on 16/10/23.
//  Copyright © 2016年 bachelor. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorViewDelegate {

    var userLogon = sharedUserAccount != nil
    var visitorView: VisitorView?
    
    override func loadView() {
        userLogon ? super.loadView() : setupVisitorView()
    }
    
    func setupVisitorView() {
        visitorView = VisitorView()
        view = visitorView
        visitorView?.visitorDelegate = self
        navigationController?.navigationBar.tintColor = UIColor.orange
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .plain, target: self, action: #selector(BaseTableViewController.registerClick))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .plain, target: self, action: #selector(BaseTableViewController.loginClick))
        
    }
    func loginClick() {
        print(#function)
        let oauth = OauthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        present(nav, animated: true, completion: nil)
    }
    func registerClick() {
        print(#function)
    }
}
